package com.zbf.cnofig;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.http.HttpCookie;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/6/23  19:27
 * 描述:
 */
@Component
public class MyGloableFilter implements GlobalFilter {
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

        ServerHttpRequest request = exchange.getRequest();
        HttpCookie token = request.getCookies().getFirst("token");

        if(token!=null){
            String value = token.getValue();
        }


        return chain.filter(exchange);
    }
}
